<template>
  <div class="bigbox">
    <div class="xianshi">
      <span @click="gohome"
        ><svg-icon iconClass="back" class="zhuo_back"></svg-icon
      ></span>
      <div>限时秒杀</div>
    </div>
    <div class="miaored">
      <div
        v-for="(item, index) in shuju"
        :key="index"
        :class="`sss ${active === index ? 'active' : ''}`"
        @click="golist(index)"
      >
        <span>{{ item.shijian }}</span>
        <span>{{ item.miaosha }}</span>
      </div>
    </div>
    <div class="reqiang">
      <h3>实时热抢</h3>
      <div class="www">
        <template v-if="shuju[active]">
          <dl
            v-for="childrenitem in shuju[active].children"
            :key="childrenitem.id"
          >
            <dt><img :src="childrenitem.img" alt="" /></dt>
            <dd>{{ childrenitem.title }}</dd>
            <dd>￥{{ childrenitem.price }}</dd>
          </dl>
        </template>
      </div>
    </div>
    <div class="foot">
      <template v-if="shuju[active]">
        <div
          class="dl"
          v-for="cccitem in shuju[active].liebiao"
          :key="cccitem.id"
        >
          <div class="dt"><img :src="cccitem.img" alt="" /></div>
          <div class="dd">
            <span class="eee">{{ cccitem.title }}</span>
            <span>￥{{ cccitem.price }}</span>
            <span @click="goinfo(cccitem)" class="rrr">立即抢购</span>
            <span class="jindutiao"
              ><van-progress
                :percentage="cccitem.num"
                pivot-text=""
                color="#ed4e4a"
                stroke-width="15"
              />
              <span class="jindu">已抢{{ cccitem.num }}%</span>
            </span>
          </div>
        </div>
      </template>
    </div>
  </div>
</template>

<script>
import axios from "axios";
export default {
  name: "Home",
  data() {
    return {
      shuju: [],
      active: 0,
    };
  },
  created() {
    axios("/getMiao").then((res) => {
      console.log(res, "res");
      this.shuju = res.list;
    });
  },
  methods: {
    golist(index) {
      this.active = index;
      console.log(this.active);
    },
    goinfo(cccitem) {
      this.$router.push({ name: "Info", params: { cccitem } });
    },
    gohome() {
      this.$router.push({ path: "/layout/home" });
    },
  },
};
</script>

<style lang="scss" scoped>
.bigbox {
  width: 100%;
  height: 100%;
  background-color: #f2f2f2;
  font-size: 18px;
}
.xianshi {
  width: 100%;
  height: 50px;
  display: flex;
  justify-content: space-around;
  padding: 0 10px;
  line-height: 50px;
  background-color: #ffffff;
  div {
    margin: 0 auto;
    padding-right: 16px;
  }
}
.miaored {
  margin-top: 5px;
  background-image: linear-gradient(to right, #f86b50, #f44645);
  width: 100%;
  height: 130px;
  display: flex;
  justify-content: space-around;
  position: relative;
}
.sss {
  display: flex;
  flex-direction: column;
  text-align: center;
  padding-top: 10px;
  color: #faaaa4;
}
.active {
  color: #fee6e2;
}
.reqiang {
  width: 90%;
  height: 170px;
  margin: 0 5%;
  background: #ffffff;
  position: absolute;
  z-index: 2;
  top: 120px;
  border-radius: 12px;
  h3 {
    margin-left: 15px;
    margin-top: 13px;
  }
}
.www {
  width: 100%;
  height: 130px;
  // background-color: cornflowerblue;
  margin-top: 5px;
  display: flex;
  overflow-x: auto;
  padding-top: 5px;
  dl {
    margin-left: 15px;
    dd {
      font-size: 12px;
    }
  }
}

.foot {
  margin-top: 120px;
  background-color: #ffffff;
  padding-top: 5px;
  .dl {
    margin: 0 10px;
    display: flex;
    .dd {
      display: flex;
      flex-direction: column;
      margin-left: 5px;
      .eee {
        text-overflow: -o-ellipsis-lastline;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
      }
      .rrr {
        width: 80px;
        height: 30px;
        border-radius: 15px;
        background-image: linear-gradient(to left, #f97f69, #ee5650);
        line-height: 30px;
        text-align: center;
        margin-top: 5px;
        font-size: 15px;
        color: #ffffff;
      }
    }
  }
}
.jindutiao {
  width: 70px;
  height: 15px;
  border-radius: 25px;
  background-color: #f6d5d0;
  margin-top: 5px;
  position: relative;
}
.jindu {
  font-weight: bolder;
  font-size: 12px;
  position: absolute;
  top: 0;
  left: 10px;
}
</style>
